<template>
	<!-- 标题部分 -->
	<view class="titlebox">
		<image class="titlebox-backimg" src="../../static/上一步.png" @click="gotoHome"></image>
		<view class="titlebox-centertext">设置中心</view>
	</view>

	<!-- 内容部分 -->
	<view class="contentbox">
		<!-- 基本信息内容部分 -->
		<view class="contentbox-basicinformation">
			<view v-for="(item, index) in profileItems" :key="index" class="contentbox-basicinformation-profilebox">
				<view class="contentbox-basicinformation-profilebox-profiletext">{{ item.text }}</view>
				<image v-if="item.img" class="contentbox-basicinformation-profilebox-profileimg" :src="item.img">
				</image>
				<view v-if="item.value" class="contentbox-basicinformation-profilebox-nicknametext"
					:class="{'verified-text': getRedText(item.value)}">{{ item.value }}</view>
				<image class="contentbox-basicinformation-profilebox-nextimg" src="../../static/下一步1.png"></image>
			</view>
		</view>

		<!-- 更多信息内容部分 -->
		<view v-for="(group, groupName) in informationItems" :key="groupName" class="contentbox-informationbox">
			<view v-for="item in group" :key="item.text" class="contentbox-informationbox-profilebox">
				<view class="contentbox-informationbox-profilebox-profiletext">{{ item.text }}</view>
				<view v-if="item.value" class="contentbox-informationbox-profilebox-nicknametext"
					:class="{'verified-text': getRedText(item.value)}">{{ item.value }}</view>
				<image class="contentbox-informationbox-profilebox-nextimg" src="../../static/下一步1.png"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 基本信息
				profileItems: [{
						text: '头像',
						img: '../../static/头像.png'
					},
					{
						text: '昵称',
						value: '爱喝咖啡的金豆'
					}
				],
				// 更多信息
				informationItems: {
					contacts: [{
							text: '手机号',
							value: '已认证'
						},
						{
							text: '微信号',
							value: '去授权'
						},
						{
							text: '淘宝授权',
							value: '去授权'
						},
						{
							text: '拼多多授权',
							value: '去授权'
						}
					],
					about: [{
							text: '关于我们'
						},
						{
							text: '隐私政策'
						},
						{
							text: '版本号',
							value: '1.2.41'
						},
						{
							text: '退出登录'
						}
					]
				}
			};
		},
		methods: {
			gotoHome() {
				// 在tabbar中使用uniapp的switchTab方法跳转
				uni.switchTab({
					url: '/pages/home/home', // 我的路径
				});
			},
			getRedText(value) {
				return value === '已认证' || value === '已设置' || value === '已授权';
			}
		}
	};
</script>

<style>
	/* 标题部分 */
	.titlebox {
		display: flex;
		padding: 2%;
		text-align: center;
		background: #F6F6F6;
	}

	.titlebox-backimg {
		width: 15px;
		height: 15px;
		display: block;
	}

	.titlebox-centertext {
		flex: 1;
		text-align: center;
		font-size: 15px;
	}

	/* 基本信息内容部分 */
	.contentbox {
		padding: 2%;
		background: #F6F6F6;
	}

	.contentbox-basicinformation,
	.contentbox-informationbox {
		background: white;
		padding: 2%;
		border-radius: 10px;
		margin-bottom: 10px;
	}

	.contentbox-informationbox-profilebox,
	.contentbox-basicinformation-profilebox {
		display: flex;
		align-items: center;
		padding: 4% 2%;
	}

	.contentbox-informationbox-profilebox-profiletext,
	.contentbox-basicinformation-profilebox-profiletext {
		font-size: 15px;
		flex: 1;
	}

	.contentbox-informationbox-profilebox-profileimg,
	.contentbox-basicinformation-profilebox-profileimg {
		width: 35px;
		height: 35px;
		display: block;
	}

	.contentbox-informationbox-profilebox-nextimg,
	.contentbox-basicinformation-profilebox-nextimg {
		width: 15px;
		height: 15px;
		margin-left: 10px;
	}

	.contentbox-informationbox-profilebox-nicknametext,
	.contentbox-basicinformation-profilebox-nicknametext {
		font-size: 15px;
		color: #bababa;
	}

	.verified-text {
		color: red;
	}
</style>
